package com.woniu.guoguo.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.guoguo.model.MenuComments;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Richie
 * @since 2020-11-04
 */
public interface MenuCommentsMapper extends BaseMapper<MenuComments> {

    @Select("select * from menu_comments where menu_id=#{menuId}")
    IPage<MenuComments> findCommentsByMenuId(Page<MenuComments> page,int menuId);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into menu_comments(menu_id,user_id,comments,score,comm_data) values(#{menuId},#{userId},#{comments},#{score},#{commData})")
    void insertAMenuComment(MenuComments menuComments);
}
